/**
 * 
 */
package com.audi.box.server.handler;

import java.util.ArrayList;

import android.util.Log;

import com.audi.box.controller.DeviceController;
import com.audi.box.controller.HistoryController;
import com.audi.box.controller.IController;
import com.audi.box.server.message.HandlerException;
import com.audi.box.server.message.ObjectCombine;
import com.audi.dto.DeviceItem;
import com.audi.dto.PlaceItem;

/**
 * @author HuyPVA
 * 
 */
public class HistoryHandler extends Handler {
	private static HistoryHandler deviceHandle;
	private static Object deviceObj = new Object();

	/**
	 * @param controller
	 */
	private HistoryHandler(IController controller) {
		super(controller);
	}

	public static HistoryHandler getInstance(IController controller) {
		if (deviceHandle == null) {
			synchronized (deviceObj) {
				if (deviceHandle == null) {
					deviceHandle = new HistoryHandler(controller);
				}
				return deviceHandle;
			}
		} else {
			return deviceHandle;
		}
	}

	/*
	 * Get DeviceController
	 */
	public HistoryController getHistoryController() {
		return (HistoryController) getController();
	}

	/*
	 * Process message by action
	 */
	@Override
	public Object process(int actionId, String data) throws HandlerException {
		Object result = null;
		DeviceItem deviceItem = null;

		switch (actionId) {
		case GET_HISTORY_LIST:
			result = getHistoryController().getHistoryList();
			break;			
		default:
			Log.e("AudiBox", "[DeviceHandler.java] Function not found" + actionId);
			throw new HandlerException("Function " + actionId +" not found!!!");
		}
		return result;
	}

}
